FROM buildpack-deps:stable

ENV LANG=C.UTF-8
# don't create ".bundle" in all our apps
ENV GEM_HOME=/usr/local/bundle
ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
    BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH=$GEM_HOME/bin:$PATH

ARG TRUFFLERUBY_VERSION

RUN set -eux ;\
    case "$(uname -m)" in \
      x86_64) arch="amd64" ;; \
      aarch64) arch="aarch64" ;; \
    esac; \
    wget -q https://github.com/truffleruby/truffleruby/releases/download/graal-$TRUFFLERUBY_VERSION/truffleruby-$TRUFFLERUBY_VERSION-linux-$arch.tar.gz ;\
    tar -xzf truffleruby-$TRUFFLERUBY_VERSION-linux-$arch.tar.gz -C /usr/local --strip-components=1 ;\
    rm truffleruby-$TRUFFLERUBY_VERSION-linux-$arch.tar.gz ;\
    /usr/local/lib/truffle/post_install_hook.sh ;\
    ruby --version ;\
    gem --version ;\
    bundle --version ;\
    mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"

CMD [ "irb" ]
